package com.cskaoyan.service;

import com.cskaoyan.mapper.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author stone
 * @date 2022/10/04 16:36
 */
@Service
public class AccountServiceImpl implements AccountService{
    @Autowired
    AccountMapper accountMapper;
    @Override
    public void transfer(Integer fromId, Integer destId, Integer money) {
        Integer fromMoney = accountMapper.selectMoneyById(fromId);
        Integer destMoney = accountMapper.selectMoneyById(destId);

        fromMoney -= money;
        destMoney += money;

        accountMapper.updateMoneyById(fromId, fromMoney);

        int i = 1 / 0;

        accountMapper.updateMoneyById(destId, destMoney);
    }
}
